import com.astar.library.Node;
import com.astar.library.NodeMap;
import com.astar.library.PathFinder;


public class MainClass {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		int cols = 30;
		int rows = 30;
		
		// make a node map with number of columns, number of rows and initial cost
		NodeMap mMap = new NodeMap(cols, rows, 1);
		
		Node startNode = mMap.getNode(0, 0);
		Node targetNode = mMap.getNode(28, 24);
		
		// set random cost of the nodes (walkable areas or not walkable etc etc)
		// lower cost mean area difficult to walk (Zero cost mean area not walkable)
		for (int X = 0; X < rows; X++)
		{
			for (int Y = 0; Y < cols; Y++)
			{
				Node node = mMap.getNode(X, Y);
				node.setCost((float)Math.random());
			}
		}
		
		// find the path
		boolean result = PathFinder.AStar(mMap, startNode, targetNode);
		
		if(result) {
			System.out.println("Path found...");
			
			// getting through the path
			while (targetNode != startNode)
			{

				System.out.println("Path to : " + targetNode.toString());
				targetNode = targetNode.getParent();
			}
		}else{
			System.out.println("Path Not found...");
		}
		


		System.out.println("program ends here...");
	}

}
